package com.tt.mymu.controller;

import com.tt.mymu.service.ToolService;
import com.tt.mymu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("tool")
public class ToolController {

    @Autowired
    private ToolService toolService;

    //@PostMapping("/upload")
    public Result uploadFile(@RequestParam("file") MultipartFile file) {
        return toolService.uploadFile(file);
    }

    @PostMapping("/delete")
    public Result deleteFile(String filePath) {
        return toolService.deleteFile(filePath);
    }

    @PostMapping("/upload")
    public Map<String, Object> upload(@RequestParam("file") MultipartFile file) throws IOException {
        return toolService.upload(file);
    }

}
